package Sort.sort;
//ϣ������
public class ShellSort {

	public static void main(String[] args) {
		int[] array={9,1,5,8,3,7,4,6,2};
		shellSort(array);
		for(int i=0;i<array.length;i++){
			System.out.print(array[i]);
		}
	}
	public static void shellSort(int[] array){
		if(array==null||array.length==0){
			return;
		}
		int i ;
		int j;
		int increment = array.length;
		do{
			increment = increment/3+1;
			for(i=increment;i<array.length;i++){
				if(array[i]<array[i-increment]){
					int temp =array[i];
					for(j=i-increment;j>=0&&array[j]>temp;j-=increment){
						array[j+increment] = array[j];
					}
					array[j+increment]=temp;
				}
			}
		}
		while(increment>1);
	}

}
